using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BlogEngine.Core;

public partial class admin_gallery_SideMenu : System.Web.UI.UserControl
{

	protected void Page_Load(object sender, EventArgs e)
	{
		Album album = null;
		string albumid = string.Empty;

		if (Request.QueryString["AlbumId"] != null)
		{
			album = Album.GetById(new Guid(Request.QueryString["AlbumId"]));
			albumid = album.Id.ToString();
		}

		Photo photo = null;
		string photoid = string.Empty;

		if (Request.QueryString["PhotoId"] != null)
		{
			photo = Photo.GetById(new Guid(Request.QueryString["PhotoId"]));
			photoid = photo.Id.ToString();
		}

		PhotoEffect photoeffect = null;
		string photoeffectid = string.Empty;

		if (Request.QueryString["PhotoEffectId"] != null)
		{
			photoeffect = PhotoEffect.GetById(new Guid(Request.QueryString["PhotoEffectId"]));
			photoeffectid = photoeffect.Id.ToString();
		}

		if ((photo != null) && (album == null) && (photoeffect == null))
		{
			album = photo.Album;
			albumid = album.Id.ToString();
		}

		AddMenu("View Photos", "ViewPhotoAlbum.aspx?AlbumId=" + albumid, "picture_go.png", album != null);
		AddMenu("Add Photo", "AddPhoto.aspx?AlbumId=" + albumid, "picture_add.png", album != null);
		AddMenu("Import Photos", "AddLocalPhotos.aspx?AlbumId=" + albumid, "pictures_add.png", album != null);
		AddMenu("Delete Photo", "DeletePhoto.aspx?PhotoId=" + photoid, "picture_delete.png", photo != null);
		AddMenu("View Albums", "ViewAlbums.aspx", "folder_go.png");
		AddMenu("Add Album", "AddAlbum.aspx", "folder_add.png");
		AddMenu("Edit Album", "EditAlbum.aspx?AlbumId=" + albumid, "folder_edit.png", album != null);
		AddMenu("Delete Album", "DeleteAlbum.aspx?AlbumId=" + albumid, "folder_delete.png", album != null);
		AddMenu("View Photo Effects", "ViewPhotoEffects.aspx", "layers_go.png");
		AddMenu("Add Photo Effect", "AddPhotoEffect.aspx", "layers_add.png");
		AddMenu("Edit Photo Effect", "EditPhotoEffect.aspx", "layers_edit.png", photoeffect != null);
		AddMenu("Delete Photo Effect", "DeletePhotoEffect.aspx", "layers_delete.png", photoeffect != null);
		AddMenu("Edit Global Settings", "GallerySettings.aspx", "cog_edit.png");
	}

	protected void AddMenu(string name, string url, string icon, bool display)
	{
		if (!display)
			return;

		if (!string.IsNullOrEmpty(icon))
		{
			HtmlImage i = new HtmlImage();
			i.Src = "icons/" + icon;
			i.Border = 0;
			Options.Controls.Add(i);
		}

		HtmlGenericControl c = new HtmlGenericControl();
		c.InnerHtml = " ";
		Options.Controls.Add(c);

		HtmlAnchor a = new HtmlAnchor();
		a.HRef = url;
		a.Title = name;
		a.InnerText = name;

		Options.Controls.Add(a);

		HtmlGenericControl n = new HtmlGenericControl();
		n.InnerHtml = "<br />";
		Options.Controls.Add(n);
	}

	protected void AddMenu(string name, string url, string icon)
	{
		AddMenu(name, url, icon, true);
	}

}
